package com.zhuangjie.order.service;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhuangjie.base.vo.PageVO;
import com.zhuangjie.order.dto.*;
import com.zhuangjie.order.entity.Order;
import com.zhuangjie.order.vo.*;

import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;

/**
 * <p>
 * 订单表 服务类
 * </p>
 *
 * @author zhuangjie
 * @since 2023-11-24
 */
public interface OrderService extends IService<Order> {

    CreateOrderCompleteVO createOrder(SubmitOrderDTO submitOrderDTO) throws Exception;


    /**
     * 待支付->已取消
     * @param orderId
     * @param cancelReason
     * @return
     */
    void cancelOrder(Long orderId, String cancelReason) throws Exception;


    void cancelOrderForMQ(Long orderId, String cancelReason) throws Exception;

    void paymentOrder(Long orderId);

    OrderInfoVO getOrderInfo(Long orderId);

    ShopOrderPageVO listShopOrder(ShopOrderPageDTO shopOrderPageDTO);

    void shopRejectOrder(ShopRejectOrderDTO shopRejectOrderDTO) throws Exception;

    void shopReceivingOrder(Long orderId);

    void productionCompleted(Long orderId);


    PageVO<OrderForUserVO> getOrderListForUser(OrderListForUserPageDTO orderListForUserPageDTO) throws Exception;

    List<OrderDetailForEvaluate> listDisheForEvaluateListByOrderId(Long orderId);

    OrderDetailForDeliveryOrderDetailVO orderDetailForDeliveryOrderDetail(Long orderId);

    void updateDeliveryOrderToDelivering(Long orderId);

    void updateDeliveryOrderToCompleted(Long orderId) throws Exception;

    Boolean isNewCustomer(Long shopId, Long userId);

    void  updateOrderStateTo(Long orderId, Integer targetState, Consumer<LambdaUpdateWrapper<Order>> updateWrapperConsumer) throws Exception;

    OrderForMapShow getOneMapShowOrderInfo(Long orderId) throws Exception;


    List<OrderForUserMapVO> listForMapShow();

    OrderForUserEvaluateVO getOrderForUserEvaluate(Long orderId);


    void submitOrderEvaluate(@Valid OrderEvaluateSubmitDTO orderForUserEvaluateVO);

    Map<Long,Long> monthSalesCount(Collection<Long> shopIds, Integer recentDays);
}
